package com.itheima.jingjie.map.map练习2;

import com.itheima.jingjie.map.map练习.Student;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Set;
import java.util.TreeMap;

public class Demo1 {
    public static void main(String[] args) {
        //HashMap<Character, Integer> hm = new HashMap<>();
        TreeMap<Character, Integer> hm = new TreeMap<>();
        //String str = "aababcabcdabcde";
        String str = "csaqedsadadfaasdqeqdaa";
        char[] chars = str.toCharArray();
        Arrays.sort(chars);
        for (char aChar : chars) {
            if (hm.containsKey(aChar)) {
                Integer integer = hm.get(aChar);
                integer++;
                hm.put(aChar,integer);
            } else {
                hm.put(aChar,1);
            }
        }
        Set<Character> characters = hm.keySet();
        for (Character character : characters) {
            System.out.print(character+"("+hm.get(character)+")");
        }

    }
}
